package sys.news.service.impl;


import sys.news.dao.TopicDao;
import sys.news.dao.impl.TopicDaoImpl;
import sys.news.pojo.Topic;
import sys.news.service.TopicService;

import java.sql.SQLException;
import java.util.List;

public class TopicServiceImpl implements TopicService {
    TopicDao topicDao = new TopicDaoImpl();
    /**
     * 增添主题
     *
     * @param topic
     * @return
     */
    @Override
    public boolean addTopic(Topic topic) throws SQLException {
        return topicDao.addTopic(topic)==1?true:false;
    }

    /**
     * 删除主题
     *
     * @param tid
     * @return
     */
    @Override
    public boolean delTopic(int tid) throws SQLException {

        return topicDao.delTopic(tid)==1?true:false;
    }

    /**
     * 修改新闻主题
     *
     * @param topic
     * @return
     */
    @Override
    public boolean updateTopic(Topic topic) throws SQLException {

        return topicDao.updateTopic(topic) == 1?true:false;
    }

    /**
     * 查询所有的主题
     *
     * @return
     */
    @Override
    public List<Topic> getAll() throws SQLException {
        return topicDao.getAll();
    }

    /**
     * 通过 主题名字查询主题
     *
     * @param tname
     * @return
     */
    @Override
    public Topic getTopicByName(String tname) throws SQLException {
        return topicDao.getTopicByName(tname);
    }
}
